package com.sunda.spmsweb.wmscontroller;


import com.sunda.spmscommon.ResponseResult;
import com.sunda.spmswms.service.IWerksService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 工厂信息表 前端控制器
 * </p>
 *
 * @author Wayne
 * @since 2020-11-24
 */
@RestController
@Api(tags = "工厂基本信息", description = "工厂基本信息接口")
@RequestMapping("/werks")
public class WerksController {

    @Autowired
    IWerksService iWerksService;

    @RequestMapping("/getWerksList")
    @ApiOperation(value = "获取全部工厂信息",notes = "获取全部工厂信息", httpMethod = "GET")
    public ResponseResult getWerksList(){
        try {
            return ResponseResult.success().add("werksList", iWerksService.getWerksList());
        }catch (Exception e){
            return ResponseResult.error("获取工厂信息出错");
        }
    }

    @RequestMapping("/getWhsByWerks")
    @ApiOperation(value = "获取工厂下全部仓库信息",notes = "获取工厂下全部仓库信息\n示例：werks = GF01", httpMethod = "POST")
    public ResponseResult getWhsByWerks(String werks){
        try {
            return ResponseResult.success().add("whsList", iWerksService.getWhsByWerks(werks));
        }catch (Exception e){
            return ResponseResult.error("获取仓库信息出错");
        }
    }

    @RequestMapping("/getWorkshopByWerks")
    @ApiOperation(value = "获取工厂下全部车间信息",notes = "获取工厂下全部车间信息\n示例：werks = GH01", httpMethod = "POST")
    public ResponseResult getWorkshopByWerks(String werks){
        try {
            return ResponseResult.success().add("workshopList", iWerksService.getWorkshopByWerks(werks));
        }catch (Exception e){
            return ResponseResult.error("获取工厂信息出错");
        }
    }
}
